package lambda;

import org.junit.jupiter.api.Test;

import javax.swing.tree.TreeSelectionModel;
import java.sql.SQLOutput;
import java.util.Arrays;
import java.util.Comparator;
import java.util.TreeSet;

/**
 * @Author: zhangxuhui
 * @Date: 2021/6/21 8:39 下午
 * @email: zxh_1633@163.com
 */
public class LambdaTest {

    @Test
    public void test03(){
        System.out.println("today is free");
    }

    /**
     * 无参数、无返回值
     */
    @Test
    public void test02(){
        Runnable run = new Runnable(){
            @Override
            public void run() {
                System.out.println("Good");
            }
        };

        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("Good");
            }
        }).start();

        Runnable r = ()-> System.out.println("Good");

        new Thread(()-> System.out.println("Good"));
    }


    /**
     * 匿名内部类
     */
    @Test
    public void test(){
        Comparator<Integer> com = new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o1.compareTo(o2);
            }
        };

        TreeSet<Integer> tree = new TreeSet<>(com);
    }

    @Test
    public void test01(){
        Comparator<Integer> com = (o1,o2)->{
            return o1.compareTo(o2);
        };
        //Comparator<Integer> com1 = (o1,o2)->o1.compareTo(o2);
        TreeSet<Integer> tree = new TreeSet<>(com);
    }


}
